package com.ft.admix.base;

import android.app.Activity;
import android.content.Context;
import android.util.Log;

import com.ft.admix.common.MixConstant;
import com.ft.admix.config.AdConfig;
import com.ft.admix.utils.AdMixLogger;

public abstract class BaseAd {
    protected AdConfig config;
    protected AdListener listener;
    protected boolean isLoaded;
    public Activity context;
    public void setAdListener(AdListener listener){
        this.listener = listener;
    }
    public abstract void load(Activity context, AdConfig config);
    public abstract void destroy();

    public void callLoadSuccess(){
        AdMixLogger.i(config.getAdId()+"--load success");
        listener.onAdLoaded();
    }

    public void callLoadSuccess(double ecpm){
        AdMixLogger.i(config.getAdId()+"--load success, ecpm = "+ecpm);
        listener.onAdLoaded();
    }

    public void callLoadFailed(int code, String msg){
        AdMixLogger.i(config.getAdId()+"--load failed : code = "+code+", msg = "+msg);
        listener.onAdError(code, msg);
    }

    public MixConstant.AdReadyStatus isReadyCondition(){
        return MixConstant.AdReadyStatus.AD_IS_READY;
    }

    public boolean isReady() {
        return isLoaded;
    }
}